/*
 * File: exercise12.cpp
 * -------------------
 * createRegularPlural function 
 * compile command :
 * g++ -Wall -g exercise12.cpp -o exercise12 -lStanfordCPPLib -I ../include/
 */

#include <iostream>
#include <string>
#include "strlib.h"
using namespace std;

string createRegularPlural(string word);

int main()
{
	cout<<"bus -> "<<createRegularPlural("bus")<<endl;
	cout<<"box -> "<<createRegularPlural("box")<<endl;
	cout<<"quiz -> "<<createRegularPlural("quiz")<<endl;
	cout<<"watch -> "<<createRegularPlural("watch")<<endl;
	cout<<"wish -> "<<createRegularPlural("wish")<<endl;
	cout<<"baby -> "<<createRegularPlural("baby")<<endl;
	cout<<"apple -> "<<createRegularPlural("apple")<<endl;
	return 0;
}

string createRegularPlural(string word)
{
	string result = "";
	if(endsWith(word,'s') || endsWith(word, 'x') || endsWith(word, 'z') || endsWith(word, "ch") || endsWith(word, "sh"))
		result = word + "es";
	else if(endsWith(word,'y'))
	{
		result = word.substr(0,word.length()-1) + "ies";
	}
	else
	{
		result = word + "s";
	}
	return result;
}
